package top.soulblack.purchasesale.service;

import lombok.extern.slf4j.Slf4j;
import org.apache.catalina.Store;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.soulblack.purchasesale.common.enums.ResultEnum;
import top.soulblack.purchasesale.exception.PurchaseException;
import top.soulblack.purchasesale.mapper.StoreGoodsMapper;
import top.soulblack.purchasesale.model.StoreGoods;

import java.math.BigInteger;
import java.util.List;

/**
 * @Author: 韦溜溜
 * @Description:
 * @Date: Create in 21:04 2019/7/17
 */
@Service
@Slf4j
public class StoreGoodsService {

    @Autowired
    private StoreGoodsMapper storeGoodsMapper;

    public List<StoreGoods> selectBygoodsId(BigInteger goodsId){
       return storeGoodsMapper.selectByGoodId(goodsId);
    }

    public List<StoreGoods> selectByGoodId( BigInteger goodsId){
       List<StoreGoods> storeGoodsList =  storeGoodsMapper.selectByGoodId(goodsId);
       if(storeGoodsList.size()==0){
           log.error("【查询库存】通过goodsId查询 goodsId={}",goodsId);
           throw new PurchaseException(ResultEnum.STOREEMPITY);
       }
       return storeGoodsList;
    }


}

